module.exports = app => {
    const { STRING, INTEGER, TEXT, DATE, BIGINT, TINYINT } = app.Sequelize;

    const Message = app.model.define('message', {
        id: {
            type: BIGINT.UNSIGNED,
            primaryKey: true,
            autoIncrement: true,
        },
        sender_id: { type: BIGINT.UNSIGNED, allowNull: false },
        receiver_id: { type: BIGINT.UNSIGNED, allowNull: false },
        message_type: { type: STRING(20), allowNull: false },
        content: { type: TEXT, allowNull: false },
        image_url: { type: STRING(255), allowNull: true },
        file_url: { type: STRING(255), allowNull: true },
        is_read: { type: TINYINT, allowNull: false, defaultValue: 0 },
        created_at: DATE,
    }, {
        tableName: 'messages',
        timestamps: false,
    });

    return Message;
};